package penguin.masking;

import java.sql.ResultSet;

/**
 * 脱敏服务
 * <p>负责完成数据脱敏并返回数据</p>
 *
 * @author wuxh
 * @version 1.0.0
 */
public class DataMaskingService {

    /**
     * Object脱敏
     *
     * @param set
     * @param columnName
     * @param v
     * @return
     */
    public static Object maskingObject(ResultSet set, Object columnName, Object v) {
        DataMaskingProcess maskingProcess = MaskingContext.context().getMaskingProcess();
        if (maskingProcess == null) {
            return v;
        }
        return maskingProcess.doMasking(set, columnName, v);
    }

    /**
     * 字符串脱敏
     *
     * @param set
     * @param columnName
     * @param v
     * @return
     */
    public static String maskingString(ResultSet set, Object columnName, String v) {
        DataMaskingProcess maskingProcess = MaskingContext.context().getMaskingProcess();
        if (maskingProcess == null) {
            return v;
        }
        return maskingProcess.doMasking(set, columnName, v);
    }

}
